package com.zen.demo.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zen.demo.sys.entity.DictLang;
import com.zen.demo.sys.mapper.DictLangMapper;
import com.zen.demo.sys.service.DictLangService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ZhengDing
 * @since 2022-01-28 23:45:54
 */
@Service
public class DictLangServiceImpl extends ServiceImpl<DictLangMapper, DictLang> implements DictLangService {

    @Override
    public String getKey(String module, String value) {
        DictLang params = DictLang.builder().module(module).value(value).build();
        DictLang result = this.getOne(new QueryWrapper<DictLang>(params));
        return result.getKey();
    }

    @Override
    public String getValue(String module, String key) {
        DictLang params = DictLang.builder().module(module).key(key).build();
        DictLang result = this.getOne(new QueryWrapper<DictLang>(params));
        return result.getValue();
    }

    @Override
    public List<Map<String, Object>> getDict(String module) {
        DictLang params = DictLang.builder().module(module).build();
        List<DictLang> list = this.list(new QueryWrapper<>(params));
        List<Map<String, Object>> maps = this.listMaps(new QueryWrapper<>(params));
        return maps;
    }
}
